$(function () {
    findDate();
})

function findDate() {
    setInterval(function () {
            let dateTime = new Date();
            let year = dateTime.getFullYear();
            let month = dateTime.getMonth() + 1;
            let ri = dateTime.getDate();
            let day = null;
            if (dateTime.getDay() == 6) {
                day = "六";
            }
            if (dateTime.getDay() == 1) {
                day = "一";
            }
            if (dateTime.getDay() == 2) {
                day = "二";
            }
            if (dateTime.getDay() == 3) {
                day = "三";
            }
            if (dateTime.getDay() == 4) {
                day = "四";
            }
            if (dateTime.getDay() == 5) {
                day = "五";
            }
            if (dateTime.getDay() == 0) {
                day = "日";
            }
            var hours = dateTime.getHours();
            var minutes = dateTime.getMinutes();
            var seconds = dateTime.getSeconds();
            $("#localDate").html(year + "年" + month + "月" + ri + "日  " + hours + ":" + minutes + ":" + seconds + "  星期" + day);
        }
        , 1000)
}

$(function () {
    setUsername();
});

function setUsername() {
    let result = myAjax('/log/getName', 'post', {token: $.cookie("token")});
    if (result.result == null) {
        location.assign("/html/login.html");
    } else {
        $("#username").html(result.result);
    }
}

//退出清除cookei
function flushCookie() {
    $.cookie("token", null, {path: "/html"});
    console.log("被调用了");
}

//赋值登录用户名
function setName() {
    sessionStorage.setItem("user-name", $("#username").text());
}

//修改密码
layui.use("layer");

function safety() {
    layer.open({
        type:2,
        anim:1,
        title:"安全设置",
        area: ['600px', '500px'],
        shadeClose: true, //点击遮罩关闭
        content: ['/html/safety.html','no'],
    })
}